import { useMemberStore } from "../store";
import type { PageResult } from "../types/global";
import type {
  PartFive,
  PartFour,
  PartFour2,
  PartOne,
  PartParams,
  PartSevenData,
  PartSixAta,
  PartSixData,
  SubjectItem,
} from "../types/part";
import http from "../utils/http";

// Part1 设置
export const postPartOneUpdate = (data: PartOne) => {
  return http<any>({
    url: "Part1/tab_update",
    method: "POST",
    data,
  });
};

// Part1 详情
export const postPartOneView = () => {
  return http<PartOne>({
    url: "Part1/member_view",
    method: "POST",
  });
};

// Part4 创建
export const postPartFourCreate = (data: PartFour) => {
  return http<any>({
    url: "Part4/create",
    method: "POST",
    data,
  });
};

// Part4 全部
export const postPartFourAll = () => {
  return http<PartFour[]>({
    url: "Part4/all",
    method: "POST",
  });
};

// Part4 修改
export const postPartFourUpdate = (data: PartFour) => {
  return http<any>({
    url: "Part4/update",
    method: "POST",
    data,
  });
};

// Part4 删除
export const postPartFourDelete = (id: number) => {
  return http<any>({
    url: "Part4/destory",
    method: "POST",
    data: {
      id,
    },
  });
};

// Part4-2 创建
export const postPartFour2Create = (data: PartFour2) => {
  return http<any>({
    url: "Part42/create",
    method: "POST",
    data,
  });
};

// Part4-2 全部
export const postPartFour2All = () => {
  return http<PartFour2[]>({
    url: "Part42/all",
    method: "POST",
  });
};

// Part4-2 修改
export const postPartFour2Update = (data: PartFour2) => {
  return http<any>({
    url: "Part42/update",
    method: "POST",
    data,
  });
};

// Part4-2 删除
export const postPartFour2Delete = (id: number) => {
  return http<any>({
    url: "Part42/destory",
    method: "POST",
    data: {
      id,
    },
  });
};

// Part5 评价修改添加
export const postPartFiveUpdate = (data: PartFive) => {
  return http<any>({
    url: "Comments/tab_update",
    method: "POST",
    data,
  });
};

// Part5 详情
export const postPartFiveView = () => {
  return http<PartFive>({
    url: "Comments/member_view",
    method: "POST",
  });
};
// Part6-ata全部数据
export const postPartSixSelectFamily = (id: string) => {
  return http<{ id: number; title: string }[]>({
    url: "AirModelPart6Subject/all?air_model_part6_id=" + id,
    method: "GET",
  });
};

// Part6-ata全部数据
export const postPartSixAta = () => {
  return http<PartSixAta[]>({
    url: "Comments/member_view",
    method: "POST",
  });
};

// Part6-engine-all
export const postPartSixEngineAll = (ids) => {
  return http<PartSixAta[]>({
    url: "Engine/all",
    method: "POST",
    data: {
      ids,
    },
  });
};

// Part6-pdf-make
export const postPartSixPdfMake = () => {
  return http<any>({
    url: "MemberPart6/mpdf",
    method: "POST",
  });
};


// Part6-data-make
export const postPartSixDataMake = () => {
  return http<any>({
    url: "MemberPart6/make",
    method: "POST",
  });
};



// Part6-data
export const postPartSixData = (data) => {
  return http<PageResult<PartSixData[]>>({
    url: "MemberPart6/index",
    method: "POST",
    data
  });
};

// Part6-data-view 查询单条数据详情
export const postPartSixDataView = (id) => {
  return http<PageResult<PartSixData[]>>({
    url: "MemberPart6/view",
    method: "POST",
    data: {
      id
    }
  });
};

// Part6-data-all
export const postPartSixDataAll = () => {
  return http<PageResult<PartSixData[]>>({
    url: "MemberPart6/all",
    method: "POST",
  });
};
// Part6-data-update
export const postPartSixDataUpdate = (data: PartSixData) => {
  return http<any>({
    url: "MemberPart6/update",
    method: "POST",
    data,
  });
};

export const postPartSixSubjectList = (
  air_model_part6_subject_id: string,
  ata_id: string
) => {
  return http<SubjectItem[]>({
    url: "subject/all",
    method: "POST",
    data: {
      air_model_part6_subject_id,
      ata_id,
    },
  });
};

// Part6-data-create
export const postPartSixDataCreate = (data: PartSixData) => {
  return http<PartSixData>({
    url: "MemberPart6/create",
    method: "POST",
    data,
  });
};

// Part6-data-delete
export const postPartSixDataDelete = (id: number) => {
  return http<PartSixData>({
    url: "MemberPart6/destory",
    method: "POST",
    data: {
      id,
    },
  });
};

// Part7统计
export const postPartSevenData = () => {
  return http<PartSevenData[]>({
    url: "MemberPart6/total",
    method: "POST",
  });
};

// 日志参数
export const postPartParamsData = () => {
  return http<PartParams[]>({
    url: "LogRemark/all",
    method: "POST",
  });
};
